package com.bwie.rent.util;

import java.util.List;

public class PageUtil<T> {

    private int page;
    private int size; //分页单位
    private long total;//总记录数
    private int pre; //上一页
    private int next; //下一页
    private int pages; //尾页
    private List<T> rows; //当前页内容

    public PageUtil() {
        System.out.println("无参构造");
    }
    // page 当前页 size 分页单位  total总记录数 rows 内容
    public PageUtil(int page, int size, long total, List<T> rows) {
        this.page = page;
        this.size = size;
        this.total = total;
        this.rows = rows;
        //计算总页数 = 总记录数 / 分页单位   5/2   4/2
        this.pages = (int) (total%size==0?total/size:(total/size +1 ));
        //上一页
        this.pre =page>1?page-1:1;
        //下一页
        this.next = page < pages?page+1:pages;

    }


    public int getPage() {
        return page;
    }

    public void setPage(int page) {
        this.page = page;
    }

    public int getSize() {
        return size;
    }

    public void setSize(int size) {
        this.size = size;
    }

    public long getTotal() {
        return total;
    }

    public void setTotal(long total) {
        this.total = total;
    }

    public int getPre() {
        return pre;
    }

    public void setPre(int pre) {
        this.pre = pre;
    }

    public int getNext() {
        return next;
    }

    public void setNext(int next) {
        this.next = next;
    }

    public int getPages() {
        return pages;
    }

    public void setPages(int pages) {
        this.pages = pages;
    }

    public List<T> getRows() {
        return rows;
    }

    public void setRows(List<T> rows) {
        this.rows = rows;
    }
}
